const http=require('../../utils/http')
Page({
    data: {
       /* movie:[],
       total:""  */
       top:[],
       tot:[],
       offset:0
    },
    /* onLoad(){
        http({           
            success:res=>{
                console.log(res.data)
                var {data,total}=res.data;                               
                this.setData({
                    movie:data,
                    total:this.handleNum(total)
                })
            }
        })       
    }, */
    /* handleNum(num){
     var arr=[]
     for(var i=0;i<num/5;i++){
         arr.push(i);

     }   
     return arr
    },
    handleItem(event){
        console.log(event)
        var {index}=event.currentTarget.dataset;
        index=index*5;
        http({
            limit:5,
            offset:index,
            success:res=>{
                var {data}=res.data;
                this.setData({
                    movies:data
                })
            }
        })
    } */


    onLoad(){
        this.sendHttp(0)
       },
         tapClick(event){
         var {index}= event.currentTarget.dataset;
         console.log(index)
         var offset = index*5;
         this.sendHttp(offset)
       },
       sendHttp(offset){
         http({
           limit:5,
           offset,
           success:res=>{
            var top = res.data.data;
            var total = res.data.total;
            var tot = []
            for(var i =0;i<total/5;i++){
                tot.push(i)
            }
            this.setData({
              top,
              tot
            })
          }
         })
       } 
})